﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using Aandelendelen.Obs;

namespace Aandelendelen.Admin
{
	public class AdminBaseForm : Page
	{
		protected override PageStatePersister PageStatePersister
		{
			get
			{
				return new SessionPageStatePersister(this);
			}
		}

		protected override void OnInit(EventArgs e)
		{
			base.OnInit(e);

			if (!this.CheckLoggedIn())
				Server.Transfer("/Expired.aspx");
		}

		private bool CheckLoggedIn()
		{
			Userinfo userInfo = (Userinfo)Session["userinfo"];

			bool loggedIn = (userInfo != null);

			if (loggedIn)
				loggedIn = userInfo.IsAdmin;

			return loggedIn;
		}
	}
}